/**
 * 处理美食译苑的数据导入,建立中餐馆和西餐馆两个样本
 * 导入包含二级分类信息,中、西餐馆均以中文为母语
 * 中文分类:
 * 逐行读入:
 * 1.行首以数字开头,且先中文后英文,判定为菜品名
 * 2.行首以数字开头，空行，忽略
 * 3.行首以中文开头，英文结束，判定为分类，分类逐层递进
 * 4.行首以英文开头，为跨行的英文名，补齐之前的英文名
 * 
 */
package net.cs.rm;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;

import net.bat.db.BaseDAOImpl;
import net.sourceforge.pinyin4j.PinyinHelper;

import org.hibernate.EntityMode;
import org.hibernate.metadata.ClassMetadata;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import dao.hb.NBase;
import dao.hb.NMenu;
import dao.hb.NRestaurant;
import dao.hb.NSort;
import dao.hb.UOrg;
import dao.hb.UUser;


class Item{
	int no;
	String name;
	String name_uk;
	String sort;
	String sort_uk;
	Item(int no,String name,String name_uk){
		this.no=no;
		this.name=name;
		this.name_uk = name_uk;
	}
	@Override
	public String toString(){
		return "no:"+no
				+"\n name:"+name
				+"\n name_uk:"+name_uk
				+"\n sort:"+sort
				+"\n sort_uk:"+sort_uk
				+"\n";
	}
}
class Sort{
	int no;
	int level;
	String name;
	String name_uk;
	int start=-1;
	int stop=-1;
	Sort psort=null;
	Sort(int no,int level,String name,String name_uk){
		this.no=no;
		this.level = level;
		this.name=name;
		this.name_uk = name_uk;
	}
	@Override
	public String toString(){
		return "no:"+no
				+"\nlevel:"+level
				+"\n name:"+name
				+"\n name_uk:"+name_uk
				+"\n sort:"+Msyy.getSortPath(psort)
				+"\n sort_uk:"+Msyy.getSortPathUk(psort)
				+"\n start:"+start
				+"\n stop:"+stop
				+"\n";
	}
}
public class Msyy {
	
	final static Logger logger = LoggerFactory.getLogger(Msyy.class);
	HashMap<Integer,Sort>  sort_map;
	HashMap<Integer,Item> item_map;
	Sort sort_last;
	Item item_last;
	Object _last;
	PicTarget pt=null;
	BaseDAOImpl dao=null;
	
	Msyy(PicTarget pt,BaseDAOImpl dao){
		this.pt=pt;
		this.dao = dao;
	}
	void init(){
		sort_map = new HashMap<Integer,Sort>();
		item_map = new HashMap<Integer,Item>();
		sort_last = null;
		item_last = null;
		_last = null;
	}
	
	void readLine(String str,int pos){
		if(str.trim().equals("")){
			//忽略时,需要结束append
			_last=null;
			return;
		}
		char ch0 = str.charAt(0);
		//注释语句
		if(ch0=='#'){
			return;
		}
		if(ch0=='>'){
			readSort(str);
			return;
		}
		if(isNum(ch0)){
			if(str.length()<10){
				//忽略时,需要结束append
				_last=null;
				return;
			}else{
				readItem(str);
				return;
			}
		}
		System.out.println("append line "+pos+"  "+ str);
		appendLast(str);
	}
	public static boolean isChe(char ch){
		//return (ch >= 0x4e00)&&(ch <= 0x9fbb);
		Character.UnicodeBlock ub = Character.UnicodeBlock.of(ch);
		if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
			    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
			    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
			    || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
			    || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
			    || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
			return true;
		}
		return false;
	}
	boolean isNum(char ch){
		return ch>=48 && ch<=57;
	}
	void appendLast(String str){
		//System.out.println(str);
		if(_last==null){
			return;
		}
		if(_last instanceof Sort){
			Sort lo = (Sort)_last;
			lo.name_uk+=str;
		}else if (_last instanceof Item){
			Item lo = (Item)_last;
			lo.name_uk+=str;
		}
	}
	void readItem(String str){
		int len = str.length();
		int pdb =0,pde=-1,pcb=-1,pce=-1,peb=-1,pee=-1;
		for(int i=0; i<len; i++){
			char ch = str.charAt(i);
			if(!isNum(ch) && pde==-1){
				pde=i-1;
			}
			if(isChe(ch)&&pcb==-1){
				pcb=i;
			}
			if(!isChe(ch)&&pcb!=-1 && pce==-1){
				pce=i-1;
				peb=i;
			}
		}
		Item item = new Item(Integer.parseInt(str.substring(pdb,pde+1)),
				str.substring(pcb,pce+1),
				str.substring(peb));
		item_map.put(item.no, item);
		//顺序混乱告警
		if(item_last!=null && item_last.no>item.no){
			System.err.println("er_no:"+item.no+" "+item.name);
		}
		item_last=item;
		_last = item;
		if(sort_last!=null && sort_last.start==-1){
			sort_last.start=item.no;
		}
	}
	void getPSort(Sort sort, Sort sort_last){
		//同级分类指向相同父节点
		if(sort.level==sort_last.level){
			sort.psort = sort_last.psort;
		}
		else if(sort.level>sort_last.level){
			sort.psort = sort_last;
		}
		else if(sort.level<sort_last.level){
			getPSort(sort,sort_last.psort);
		}
	}
	void readSort(String str){
		int len = str.length();
		int pdb =0,pde=-1,pcb=-1,pce=-1,peb=-1,pee=-1;
		for(int i=0; i<len; i++){
			char ch = str.charAt(i);
			if(ch!='>' && pde==-1){
				pde=i-1;
			}
			if(isChe(ch)&&pcb==-1){
				pcb=i;
			}
			if(!isChe(ch)&&pcb!=-1 && pce==-1){
				pce=i-1;
				peb=i;
			}
		}
		String name="";
		if(pcb!=-1 && pce!=-1){
			name =str.substring(pcb,pce+1); 
		}
		String name_uk="";
		if(peb!=-1){
			name_uk = str.substring(peb);
		}
		int no = sort_map.size()+1;
		Sort sort = new Sort(no,pde-pdb,name,name_uk);
		sort_map.put(no, sort);
		if(sort_last!=null){
			getPSort(sort,sort_last);	
			if(item_last!=null){
				sort_last.stop=item_last.no;
			}
		}
		sort_last = sort;
		_last = sort;
	}
	String getPSortByNo(Item item){
		Iterator<Entry<Integer,Sort>> iter = sort_map.entrySet().iterator(); 
		String sort=null;
		String sort_uk=null;
		while (iter.hasNext()) { 
			Entry<Integer,Sort> entry = iter.next(); 
			Sort cur = entry.getValue(); 
			if(cur.start==-1 || cur.stop==-1){
				continue;
			}
			if(item.no >= cur.start && item.no<=cur.stop){
				if(sort==null){
					sort = getSortPath(cur);
					sort_uk = getSortPathUk(cur);
				}else{
					sort=sort+";"+getSortPath(cur);
					sort_uk =sort_uk+";"+ getSortPathUk(cur);
				}
			}
		} 	
		item.sort=sort;
		item.sort_uk=sort_uk;
		return sort;
	}
	static public String getSortPath(Sort st){
		if(st==null){
			return "";
		}
		if(st.psort!=null){
			return getSortPath(st.psort)+"#"+st.name;
		}else{
			return st.name;
		}
	}
	static public String getSortPathUk(Sort st){
		if(st==null){
			return "";
		}
		if(st.psort!=null){
			return getSortPathUk(st.psort)+"#"+st.name_uk;
		}else{
			return st.name_uk;
		}
	}

	
	void readFile(String fpath) throws Exception{
		init();
		String charsetName = "UTF-8"; 
		//逐行处理,建立结构化数据
		File file = new File(fpath);
		if (file.isFile() && file.exists()) 
		{
			InputStreamReader insReader = new InputStreamReader(
					new FileInputStream(file), charsetName);

			BufferedReader bufReader = new BufferedReader(insReader);

			String line = new String();
			int pos=0;
			while ((line = bufReader.readLine()) != null) {
				//System.out.println(line);
				pos++;
				readLine(line,pos);
				
			}
			bufReader.close();
			insReader.close();
		}
		//处理最后一行
		if(sort_last!=null && item_last!=null){
			sort_last.stop=item_last.no;
		}

		System.out.println("sort size:"+sort_map.size()+"  item size:"+item_map.size());
		//处理分类指向
		int cout=0;
		Iterator<Entry<Integer,Item>> iter = item_map.entrySet().iterator(); 
		while (iter.hasNext()) { 
			Entry<Integer,Item> entry = iter.next(); 
			Item cur = entry.getValue();
			getPSortByNo(cur);
			if(cur.sort==null){
				System.err.println("err sort:"+cur.no+" "+cur.name);
			}else{
				if(pt!=null){
					String pic = pt.findPic(cur.name);
					if(pic!=null){
						cout++;
						//System.out.println("matched name:"+cur.name+" pic:"+pic);
					}else{
						System.out.println("not matched name:"+cur.name+"  "+cur.name_uk);
					}
				}
			}
			//System.out.println(cur);
		} 											
		System.out.println("matched cout:"+cout);		
	}
	public void level3to2(){
		//将3级分类拆分为2级分类,并确保菜品可以匹配拆分后的两种分类表达 >菜品分类>>热菜类>>>猪肉 拆分为>菜品分类>>热菜类 和 >热菜类>>猪肉
		//菜品分类>>热菜类 的范围扩大为其下所有子分类的并集,并且不再指向 热菜
		HashMap<Integer,Sort>  smap=new HashMap<Integer,Sort>();		
		Iterator<Entry<Integer,Sort>> iter_sort = sort_map.entrySet().iterator(); 
		while (iter_sort.hasNext()) { 
			Entry<Integer,Sort> entry = iter_sort.next(); 
			Sort cur = entry.getValue();
			if(cur.level==2){
				Sort pcur = cur.psort;
				//扩大父节点范围
				if(cur.start<pcur.start || pcur.start==-1){
					pcur.start=cur.start;
				}
				if(cur.stop>pcur.stop || pcur.stop==-1){
					pcur.stop = cur.stop;
				}
				//改变指向
				Sort ncur = smap.get(pcur.no);
				if(ncur==null){
					//新建一个一级分类
					 ncur = new Sort(pcur.no,0,pcur.name,pcur.name_uk);
					 smap.put(pcur.no, ncur);
				}
				cur.psort = ncur;
				cur.level=1;
			}
		} 	
		int cout=0;
		int len = sort_map.size();
		System.out.println("old size:"+len);
		iter_sort = smap.entrySet().iterator(); 
		while (iter_sort.hasNext()) { 
			Entry<Integer,Sort> entry = iter_sort.next(); 
			Sort cur = entry.getValue();
			cout++;
			sort_map.put(len+cout, cur);
		}
		smap.clear();
		
		//处理分类指向
		Iterator<Entry<Integer,Item>> iter = item_map.entrySet().iterator(); 
		while (iter.hasNext()) { 
			Entry<Integer,Item> entry = iter.next(); 
			Item cur = entry.getValue();
			getPSortByNo(cur);
			if(cur.sort==null){
				System.err.println("err sort:"+cur.no+" "+cur.name);
			}else{
				if(pt!=null){
					String pic = pt.findPic(cur.name);
					if(pic!=null){
						cout++;
						//System.out.println("matched name:"+cur.name+" pic:"+pic);
					}else{
						System.out.println("not matched name:"+cur.name+"  "+cur.name_uk);
					}
				}
			}
			//System.out.println(cur);
		} 											
		System.out.println("matched cout:"+cout);		
		
	}
	private void clearNode(NBase cur){
		System.out.println("delete Node id:"+cur.getId()+" itype:"+cur.getItype());
		List ls;
		//删除翻译节点 翻译节点不会成为其他节点的目标翻译节点
		if(cur.getTnid()==null){
			ls = dao.find("from NBase where tnid=?",new Object[]{cur.getId()});
			for(int i=0; i<ls.size(); i++){
				NBase tn = (NBase)ls.get(i);
				clearNode(tn);
			}
		}
		switch(cur.getItype()){
		case JSonOut.TYPE_NODE_IMAGE:
			//删除历史版本
			dao.deleteByQuery("delete from NImage where nid=?", new Object[]{cur.getId()});
			//删除自己
			dao.delete(cur);
			break;
		case JSonOut.TYPE_NODE_RESTAURANT:
			//删除关联节点
			ls = dao.find("from NBase where pnid=?",new Object[]{cur.getId()});
			for(int i=0; i<ls.size(); i++){
				NBase pn = (NBase)ls.get(i);
				clearNode(pn);
			}
			//删除历史版本
			//dao.deleteByQuery("delete from NRestaurant where nid=?", new Object[]{cur.getId()});
			//不删除自己
			//删除分类
			dao.deleteByQuery("delete from NSort where nid=?", new Object[]{cur.getId()});
			break;
		case JSonOut.TYPE_NODE_MENU:
			//删除关联节点
			ls = dao.find("from NBase where pnid=?",new Object[]{cur.getId()});
			for(int i=0; i<ls.size(); i++){
				NBase pn = (NBase)ls.get(i);
				clearNode(pn);
			}
			//删除历史版本
			dao.deleteByQuery("delete from NMenu where nid=?", new Object[]{cur.getId()});
			//删除自己
			dao.delete(cur);
			break;
		}
	}
	public void outputToDB(String rn,String trn,int uid) throws Exception{
		String cn = "dao.hb.NBase";
		String cnr = "dao.hb.NRestaurant";
		Date tm_start= new Date();
		NBase nb  =(NBase) dao.get("from NBase where title=?", new Object[]{rn});
		NBase tnb;
		//找到母语节点,如果没有建立之
		if(nb!=null){
			clearNode(nb);
			tnb=(NBase)dao.get("from NBase where tnid=?", nb.getId());
		}else{
			Date dt = new Date();
			ClassMetadata cm=dao.getClassMeta(cn);		
			ClassMetadata cmr=dao.getClassMeta(cnr);	
			nb= (NBase)cm.instantiate(null,EntityMode.POJO);
			nb.setTitle(rn);
			nb.setItype(JSonOut.TYPE_NODE_RESTAURANT);
			nb.setLanguage("zh");
			nb.setDtCreate(dt);
			nb.setUid(uid);
			dao.save(nb);
			
			NRestaurant rb = (NRestaurant)cmr.instantiate(null,EntityMode.POJO);
			rb.setNid(nb.getId());
			rb.setTitle(nb.getTitle());
			rb.setDtCreate(dt);
			rb.setUid(uid);
			dao.save(rb);
			nb.setVid(rb.getId());
			dao.update(nb);
			
			tnb = (NBase)cm.instantiate(null,EntityMode.POJO);
			tnb.setTnid(nb.getId());
			tnb.setTitle(trn);
			tnb.setItype(JSonOut.TYPE_NODE_RESTAURANT);
			tnb.setLanguage("en");
			tnb.setDtCreate(dt);
			tnb.setUid(uid);
			dao.save(tnb);
			
			NRestaurant trb = (NRestaurant)cmr.instantiate(null,EntityMode.POJO);
			trb.setNid(tnb.getId());
			trb.setTitle(tnb.getTitle());
			trb.setDtCreate(dt);
			trb.setUid(uid);
			dao.save(trb);
			tnb.setVid(trb.getId());
			dao.update(tnb);
						
		}
		Date tm_clear = new Date();
		//写入母语分类
		outputSort(nb.getId(),false,uid);
		//写入en分类
		outputSort(tnb.getId(),true,uid);
		Date tm_sort = new Date();
		//写入母语item和en item
		outputItem(nb.getId(),uid);
		System.out.println("span clear:"+(tm_clear.getTime()-tm_start.getTime())
				+" sort:"+(tm_sort.getTime()-tm_clear.getTime())
				+" item:"+(new Date().getTime()-tm_sort.getTime()));
	}
	public void outputItem(int rid, int uid){
		String cb = "dao.hb.NBase";
		ClassMetadata cmb=dao.getClassMeta(cb);
		String cm = "dao.hb.NMenu";
		ClassMetadata cmm=dao.getClassMeta(cm);
		Date dt = new Date();

		NBase tnb0=(NBase)dao.get("from NBase where tnid=?", rid);

		Iterator<Entry<Integer,Item>> iter = item_map.entrySet().iterator(); 
		while (iter.hasNext()) { 
			Entry<Integer,Item> entry = iter.next(); 
			Item cur = entry.getValue();
			NBase nb = (NBase)cmb.instantiate(null,EntityMode.POJO);
			nb.setItype(JSonOut.TYPE_NODE_MENU);
			nb.setPnid(rid);
			nb.setTitle(cur.name);
			nb.setDtCreate(dt);
			nb.setUid(uid);
			nb.setLanguage("zh");
			dao.save(nb);
			
			NMenu nm = (NMenu)cmm.instantiate(null,EntityMode.POJO);
			nm.setTitle(nb.getTitle());
			nm.setNid(nb.getId());
			nm.setDtCreate(dt);
			nm.setStype(cur.sort);
			nm.setUid(uid);
			dao.save(nm);
			nb.setVid(nm.getId());
			dao.update(nb);
			System.out.println("output item_zh:"+nb.getId());
			
			NBase tnb = (NBase)cmb.instantiate(null,EntityMode.POJO);
			tnb.setItype(JSonOut.TYPE_NODE_MENU);
			if(tnb0!=null){
				tnb.setPnid(tnb0.getId());
			}
			tnb.setTnid(nb.getId());
			tnb.setTitle(cur.name_uk);
			tnb.setDtCreate(dt);
			tnb.setUid(uid);
			tnb.setLanguage("en");
			dao.save(tnb);
			
			NMenu tnm = (NMenu)cmm.instantiate(null,EntityMode.POJO);
			tnm.setTitle(tnb.getTitle());
			tnm.setNid(tnb.getId());
			tnm.setDtCreate(dt);
			tnm.setStype(cur.sort_uk);
			tnm.setUid(uid);
			dao.save(tnm);
			tnb.setVid(tnm.getId());
			dao.update(tnb);
			System.out.println("output item_en:"+tnb.getId());
			if(pt!=null){
				String pic = pt.findPic(cur.name);
				if(pic!=null){
					//TODO create NBase Image
					//System.out.println("matched name:"+cur.name+" pic:"+pic);
				}else{
					//System.out.println("not matched name:"+cur.name+"  "+cur.name_uk);
				}
			}
			
		} 											
		
	}
	public void outputSort(int rid,boolean bUk,int uid){
		String cn = "dao.hb.NSort";
		ClassMetadata cm=dao.getClassMeta(cn);
		Date dt = new Date();
		//写入数据库,获得id
		Iterator<Entry<Integer,Sort>> iter_sort = sort_map.entrySet().iterator(); 
		while (iter_sort.hasNext()) { 
			Entry<Integer,Sort> entry = iter_sort.next(); 
			Sort cur = entry.getValue();
			NSort ns =  (NSort)cm.instantiate(null,EntityMode.POJO);
			ns.setNid(rid);
			ns.setDtCreate(dt);
			ns.setUid(uid);
			if(bUk){
				ns.setTitle(cur.name_uk);
			}else{
				ns.setTitle(cur.name);
			}
			dao.save(ns);
			cur.no=ns.getId();
		}
		//根据id建立pid指向
		iter_sort = sort_map.entrySet().iterator(); 
		while (iter_sort.hasNext()) { 
			Entry<Integer,Sort> entry = iter_sort.next(); 
			Sort cur = entry.getValue();
			if(cur.psort==null){
				continue;
			}
			NSort ns =  (NSort)dao.get("from NSort where id=?", new Object[]{cur.no});
			ns.setPid(cur.psort.no);
			dao.update(ns);
			cur.no=ns.getId();
		}
	}
	//找到菜品并将匹配到的,赋予图片
	public void buildPicPath(){
		
	}
	/**
	 * @param args
	 */
	 public static void fillOrgUser(BaseDAOImpl bdi) throws JSONException{
		 
			
 		 String str1="[{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"count\":6,\"deleteEntity\":0,\"orgName\":\"总裁办\"},{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"count\":5,\"deleteEntity\":0,\"orgName\":\"财务部\"},{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"count\":5,\"deleteEntity\":0,\"orgName\":\"综合部\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"count\":20,\"deleteEntity\":0,\"orgName\":\"软件工程部\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"count\":11,\"deleteEntity\":0,\"orgName\":\"产品研发部\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"count\":41,\"deleteEntity\":0,\"orgName\":\"系统集成部\"},{\"orgId\":\"7b47e54b-2918-48a0-aefb-d3502bb71396\",\"count\":3,\"deleteEntity\":0,\"orgName\":\"客服部\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"count\":4,\"deleteEntity\":0,\"orgName\":\"智能工程部\"},{\"orgId\":\"f9bd968e-74f2-47b6-be1e-188406e2b299\",\"count\":2,\"deleteEntity\":0,\"orgName\":\"市场部\"},{\"orgId\":\"test\",\"count\":4,\"deleteEntity\":0,\"orgName\":\"测试部门\"},{\"orgId\":\"28c007ed-c9b8-4c01-8b4f-00d746f56573\",\"count\":1,\"deleteEntity\":0,\"orgName\":\"外部用户组\"}]";

		 String []  staArray={"[{\"orgId\":\"f9bd968e-74f2-47b6-be1e-188406e2b299\",\"loginId\":\"zhangxw\",\"username\":\"张星炜\",\"email\":\"zhangxw@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhangxw\",\"orgName\":\"市场部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"f9bd968e-74f2-47b6-be1e-188406e2b299\",\"loginId\":\"yangzx\",\"username\":\"杨子萱\",\"email\":\"yangzx@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yangzx\",\"orgName\":\"市场部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
				              "[{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"wangjuan\",\"username\":\"王娟\",\"email\":\"wangjuan@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjuan\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"lixin\",\"username\":\"李昕\",\"email\":\"lixin@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lixin\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"hanmin\",\"username\":\"韩敏\",\"email\":\"hanmin@sinosoftech.com\",\"tel\":\"\",\"userId\":\"hanmin\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"wangjc\",\"username\":\"王金成\",\"email\":\"wangjc@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjc\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
				              "[{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"wangjuan\",\"username\":\"王娟\",\"email\":\"wangjuan@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjuan\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"lixin\",\"username\":\"李昕\",\"email\":\"lixin@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lixin\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"hanmin\",\"username\":\"韩敏\",\"email\":\"hanmin@sinosoftech.com\",\"tel\":\"\",\"userId\":\"hanmin\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"e944d9ca-b9d0-4c7e-80e5-22c73ec84a7b\",\"loginId\":\"wangjc\",\"username\":\"王金成\",\"email\":\"wangjc@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjc\",\"orgName\":\"智能工程部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"7b47e54b-2918-48a0-aefb-d3502bb71396\",\"loginId\":\"fangyi\",\"username\":\"房毅\",\"email\":\"fangyi@sinosoftech.com\",\"tel\":\"\",\"userId\":\"fangyi\",\"orgName\":\"客服部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"7b47e54b-2918-48a0-aefb-d3502bb71396\",\"loginId\":\"fengribing\",\"username\":\"丰日兵\",\"email\":\"fengribing@sinosoftech.com\",\"tel\":\"\",\"userId\":\"fengribing\",\"orgName\":\"客服部\",\"loginType\":\"local\",\"userType\":\"2\"},{\"orgId\":\"7b47e54b-2918-48a0-aefb-d3502bb71396\",\"loginId\":\"xuexb\",\"username\":\"薛喜斌\",\"email\":\"xuexb@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xuexb\",\"orgName\":\"客服部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liusong\",\"username\":\"刘嵩\",\"email\":\"liusong@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liusong\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"songcw\",\"username\":\"宋成为\",\"email\":\"songcw@sinosoftech.com\",\"tel\":\"\",\"userId\":\"songcw\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liupeng\",\"username\":\"刘鹏\",\"email\":\"liupeng@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liupeng\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"changying\",\"username\":\"常颖\",\"email\":\"changying@sinosoftech.com\",\"tel\":\"\",\"userId\":\"changying\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhengchen\",\"username\":\"郑晨\",\"email\":\"zhengchen@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhengchen\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liuwy\",\"username\":\"刘位一\",\"email\":\"liuwy@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liuwy\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhangbo\",\"username\":\"张博\",\"email\":\"zhangbo@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhangbo\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"lrf\",\"username\":\"梁汝峰\",\"email\":\"lrf@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lrf\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"jianghw\",\"username\":\"姜宏伟\",\"email\":\"jianghw@sinosoftech.com\",\"tel\":\"\",\"userId\":\"jianghw\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"yudq\",\"username\":\"于大千\",\"email\":\"yudq@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yudq\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"guanhm\",\"username\":\"管浩明\",\"email\":\"guanhm@sinosoftech.com\",\"tel\":\"13552977330\",\"userId\":\"guanhm\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"caobz\",\"username\":\"曹宝璋\",\"email\":\"caobz@sinosoftech.com\",\"tel\":\"\",\"userId\":\"caobz\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"fengdq\",\"username\":\"冯丹青\",\"email\":\"fengdq@sinosoftech.com\",\"tel\":\"\",\"userId\":\"fengdq\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhangsw\",\"username\":\"张书玮\",\"email\":\"zhangsw@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhangsw\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"xuxiang\",\"username\":\"许翔\",\"email\":\"xuxiang@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xuxiang\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"wangwei\",\"username\":\"王伟\",\"email\":\"wangwei@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangwei\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhaona\",\"username\":\"赵娜\",\"email\":\"zhaona@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhaona\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liuzq\",\"username\":\"刘仲乔\",\"email\":\"liuzq@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liuzq\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"licy\",\"username\":\"李澄宇\",\"email\":\"licy@sinosoftech.com\",\"tel\":\"\",\"userId\":\"licy\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"renhong\",\"username\":\"任宏\",\"email\":\"renhong@sinosoftech.com\",\"tel\":\"\",\"userId\":\"renhong\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"xple\",\"username\":\"乐筱萍\",\"email\":\"xple@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xple\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"2\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"cuimeng\",\"username\":\"崔萌\",\"email\":\"cuimeng@sinosoftech.com\",\"tel\":\"\",\"userId\":\"cuimeng\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"chenyp\",\"username\":\"陈钰平\",\"email\":\"chenyp@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chenyp\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"peiff\",\"username\":\"裴菲菲\",\"email\":\"peiff@sinosoftech.com\",\"tel\":\"\",\"userId\":\"peiff\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"yinyue\",\"username\":\"殷越\",\"email\":\"yinyue@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yinyue\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liugw\",\"username\":\"刘钢伟\",\"email\":\"liugw@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liugw\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"xuejb\",\"username\":\"薛建彬\",\"email\":\"xuejb@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xuejb\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhouzq\",\"username\":\"周志强\",\"email\":\"zhouzq@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhouzq\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"Liucx\",\"username\":\"刘春晓\",\"email\":\"Liucx@sinosoftech.com\",\"tel\":\"\",\"userId\":\"Liucx\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"tianyong\",\"username\":\"田勇\",\"email\":\"tianyong@sinosoftech.com\",\"tel\":\"\",\"userId\":\"tianyong\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhouxt\",\"username\":\"周鑫婷\",\"email\":\"zhouxt@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhouxt\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"sunmy\",\"username\":\"孙明月\",\"email\":\"sunmy@sinosoftech.com\",\"tel\":\"\",\"userId\":\"sunmy\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"qiaolf\",\"username\":\"乔莉芬\",\"email\":\"qiaolf@sinosoftech.com\",\"tel\":\"\",\"userId\":\"qiaolf\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"sujie\",\"username\":\"苏洁\",\"email\":\"sujie@sinosoftech.com\",\"tel\":\"\",\"userId\":\"sujie\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"wanglimin\",\"username\":\"王利民\",\"email\":\"wanglimin@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wanglimin\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"haoyh\",\"username\":\"郝永红\",\"email\":\"haoyh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"haoyh\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"chengtao\",\"username\":\"程韬\",\"email\":\"chengtao@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chengtao\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"mengqh\",\"username\":\"孟庆晖\",\"email\":\"mengqh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"mengqh\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"baijie\",\"username\":\"白洁\",\"email\":\"baijie@sinosoftech.com\",\"tel\":\"\",\"userId\":\"baijie\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"liuxi\",\"username\":\"刘溪\",\"email\":\"liuxi@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liuxi\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"5039f5e5-752c-495e-ad73-b811e3777de1\",\"loginId\":\"zhaowb\",\"username\":\"赵兀斌\",\"email\":\"zhaowb@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhaowb\",\"orgName\":\"系统集成部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"zhaohj\",\"username\":\"赵焕军\",\"email\":\"zhaohj@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhaohj\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"2\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"wangjia\",\"username\":\"王嘉\",\"email\":\"wangjia@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjia\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"taoj\",\"username\":\"陶洁\",\"email\":\"taoj@sinosoftech.com\",\"tel\":\"\",\"userId\":\"taoj\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"hegx\",\"username\":\"何更喜\",\"email\":\"hegx@sinosoftech.com\",\"tel\":\"\",\"userId\":\"hegx\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"chenxz\",\"username\":\"陈宪章\",\"email\":\"chenxz@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chenxz\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"jiangbuyun\",\"username\":\"蒋步云\",\"email\":\"jiangbuyun@sinosoftech.com\",\"tel\":\"\",\"userId\":\"jiangbuyun\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"yangwen\",\"username\":\"杨文\",\"email\":\"yangwen@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yangwen\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"qiaozm\",\"username\":\"乔照民\",\"email\":\"qiaozm@sinosoftech.com\",\"tel\":\"\",\"userId\":\"qiaozm\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"chenxzh\",\"username\":\"陈宪章\",\"email\":\"chenxzh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chenxzh\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"xuty\",\"username\":\"徐天元\",\"email\":\"xuty@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xuty\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"172b330a-b4fa-43e4-982e-73c064d303d6\",\"loginId\":\"yangym\",\"username\":\"杨雅敏\",\"email\":\"yangym@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yangym\",\"orgName\":\"产品研发部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"sunfu\",\"username\":\"孙芙\",\"email\":\"sunfu@sinosoftech.com\",\"tel\":\"\",\"userId\":\"sunfu\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"lianggeng\",\"username\":\"梁赓\",\"email\":\"lianggeng@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lianggeng\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"zhuqm\",\"username\":\"朱清明\",\"email\":\"zhuqm@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhuqm\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"licx\",\"username\":\"李春晓\",\"email\":\"licx@sinosoftech.com\",\"tel\":\"13311191085\",\"userId\":\"licx\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"yangxp\",\"username\":\"杨学平\",\"email\":\"yangxp@sinosoftech.com\",\"tel\":\"\",\"userId\":\"yangxp\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"adfe095c-2bc1-4f98-9437-c045e928f699\",\"loginId\":\"zhuwl\",\"username\":\"朱文龙\",\"email\":\"zhuwl@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhuwl\",\"orgName\":\"总裁办\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"loginId\":\"zhaolx\",\"username\":\"赵林选\",\"email\":\"zhaolx@sinosoftech.com\",\"tel\":\"\",\"userId\":\"zhaolx\",\"orgName\":\"财务部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"loginId\":\"kongfr\",\"username\":\"孔繁荣\",\"email\":\"kongfr@sinosoftech.com\",\"tel\":\"\",\"userId\":\"kongfr\",\"orgName\":\"财务部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"loginId\":\"liyz\",\"username\":\"李银哲\",\"email\":\"liyz@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liyz\",\"orgName\":\"财务部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"loginId\":\"changshuang\",\"username\":\"常爽\",\"email\":\"changshuang@sinosoftech.com\",\"tel\":\"\",\"userId\":\"changshuang\",\"orgName\":\"财务部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9830fffc-fe5e-4f5e-b004-2a775642f0ac\",\"loginId\":\"weiyang\",\"username\":\"尉洋\",\"email\":\"weiyang@sinosoftech.com\",\"tel\":\"\",\"userId\":\"weiyang\",\"orgName\":\"财务部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"loginId\":\"wangpei\",\"username\":\"王裴\",\"email\":\"wangpei@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangpei\",\"orgName\":\"综合部\",\"loginType\":\"local\",\"userType\":\"2\"},{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"loginId\":\"qiwb\",\"username\":\"祁文博\",\"email\":\"qiwb@sinosoftech.com\",\"tel\":\"\",\"userId\":\"qiwb\",\"orgName\":\"综合部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"loginId\":\"dongnan\",\"username\":\"董楠\",\"email\":\"dongnan@sinosoftech.com\",\"tel\":\"\",\"userId\":\"dongnan\",\"orgName\":\"综合部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"loginId\":\"cuizhe\",\"username\":\"崔哲（综合部）\",\"email\":\"cuizhe@sinosoftech.com\",\"tel\":\"\",\"userId\":\"cuizhe\",\"orgName\":\"综合部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"decb42bf-79db-498b-b258-8344ba6c7368\",\"loginId\":\"kongcq\",\"username\":\"孔垂强\",\"email\":\"kongcq@sinosoftech.com\",\"tel\":\"\",\"userId\":\"kongcq\",\"orgName\":\"综合部\",\"loginType\":\"local\",\"userType\":\"1\"}]",
		                      "[{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"liujian\",\"username\":\"刘健\",\"email\":\"liujian@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liujian\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"pengxcgx\",\"username\":\"彭现陈共享\",\"email\":\"\",\"tel\":\"\",\"userId\":\"40f98732-9eb4-482b-ac54-2b98fd54dda4\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"chensheng\",\"username\":\"陈胜\",\"email\":\"chensheng@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chensheng\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"wangjh\",\"username\":\"王继华\",\"email\":\"wangjh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangjh\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"xurui\",\"username\":\"徐睿\",\"email\":\"xurui@sinosoftech.com\",\"tel\":\"13910000711\",\"userId\":\"xurui\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"wangtao\",\"username\":\"汪涛\",\"email\":\"wangtao@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangtao\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"xuyl\",\"username\":\"徐雅莉\",\"email\":\"xuyl@sinosoftech.com\",\"tel\":\"\",\"userId\":\"xuyl\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"renguodong\",\"username\":\"任国栋\",\"email\":\"renguodong@sinosoftech.com\",\"tel\":\"\",\"userId\":\"renguodong\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"2\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"lvxl\",\"username\":\"吕新亮\",\"email\":\"lvxl@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lvxl\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"chenlh\",\"username\":\"陈林华\",\"email\":\"chenlh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chenlh\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"konglm\",\"username\":\"孔路明\",\"email\":\"konglm@sinosoftech.com\",\"tel\":\"\",\"userId\":\"konglm\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"chengxj\",\"username\":\"程小进\",\"email\":\"chengxj@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chengxj\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"liaosp\",\"username\":\"廖素萍\",\"email\":\"liaosp@sinosoftech.com\",\"tel\":\"\",\"userId\":\"liaosp\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"fucj\",\"username\":\"付春娟\",\"email\":\"fucj@sinosoftech.com\",\"tel\":\"\",\"userId\":\"fucj\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"chentao\",\"username\":\"陈涛\",\"email\":\"chentao@sinosoftech.com\",\"tel\":\"\",\"userId\":\"chentao\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"goulm\",\"username\":\"勾立明\",\"email\":\"goulm@sinosoftech.com\",\"tel\":\"\",\"userId\":\"goulm\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"wangdh\",\"username\":\"王东华\",\"email\":\"wangdh@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangdh\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"lixl\",\"username\":\"李新蕾\",\"email\":\"lixl@sinosoftech.com\",\"tel\":\"\",\"userId\":\"lixl\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"pengxc\",\"username\":\"彭现陈 \",\"email\":\"pengxc@sinosoftech.com\",\"tel\":\"\",\"userId\":\"pengxc\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"},{\"orgId\":\"9e189c5d-b45c-4ce8-8ec9-ec3b95fd19b2\",\"loginId\":\"wangchun\",\"username\":\"王纯\",\"email\":\"wangchun@sinosoftech.com\",\"tel\":\"\",\"userId\":\"wangchun\",\"orgName\":\"软件工程部\",\"loginType\":\"local\",\"userType\":\"1\"}]"
	                        };
		 HashMap orgMap = new HashMap();
	      //保存部门  u_org表
		 bdi.deleteByQuery("delete from dao.hb.UOrg",null);
		 bdi.deleteByQuery("delete from UUser where id >?",new Object[]{9});
         JSONArray array1=new JSONArray(str1);
          for(int i=0;i<array1.length();i++){
            String  oid=array1.get(i).toString();
     		 JSONObject obj=new JSONObject(oid);
     		 UOrg uorg=new UOrg();
     		     uorg.setOid(obj.get("orgId").toString());
     		     uorg.setName(obj.get("orgName").toString());
     		     uorg.setUid(1);
     		     bdi.save(uorg);
     		    orgMap.put(obj.get("orgId"), uorg);
          }
          
          //保存员工信息 u_user
	      for (String str : staArray) {	    	  
	    	  JSONArray array=new JSONArray(str);
	           for(int j=0;j<array.length();j++){
	             String  oid=array.get(j).toString();
	      		 JSONObject obj=new JSONObject(oid);
	      		 UUser user=new UUser();
	      		    
	      		    user.setUserId(obj.get("userId").toString());
	      		    user.setName(obj.get("username").toString());
	      		    user.setEmail(obj.get("email").toString());
	      		    user.setTel(obj.get("tel").toString());
	      		    user.setGid(6);
	      		    user.setUid(1);
	      		    UOrg uorg = (UOrg)orgMap.get(obj.get("orgId"));
	      		    if(uorg!=null) {
						user.setOid(uorg.getId());
					}
	      		    bdi.save(user);
	           }	
	      }
	 }
	
	public static String getPinYinHeadChar(String str) {
		if(str==null) {
			return null;
		}
        String convert = "";
        for (int j = 0; j < str.length(); j++) {
            char word = str.charAt(j);
            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
            if (pinyinArray != null) {
                convert += pinyinArray[0].charAt(0);
            } else {
                convert += word;
            }
        }
        return convert;
    }
	
	public static void setPYH(BaseDAOImpl bdi){
		List ls = bdi.find("from UUser");
		for(int i=0; i<ls.size(); i++){
			UUser cur = (UUser)ls.get(i);
			cur.setNamePyh(getPinYinHeadChar(cur.getName()));
			bdi.update(cur);
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			//从spring加载数据库访问类
	        logger.info("Initializing Spring context.");	        
	        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/applicationContext-common.xml");	        
	        BaseDAOImpl dao = (BaseDAOImpl) applicationContext.getBean("BaseDAOImpl");
	        
	        setPYH(dao);
	        //fillOrgUser(dao);
	        
	        if(true){
	        	return;
	        }
	        
	        List ls = dao.find("from NBase");
	        logger.info("Spring context initialized.");
	        
			//PicTarget pt = new PicTarget();
			//pt.buildMapByIndexFile("/Users/chen4w/Documents/workspace/ipcm/WebRoot/st2/examples/rm/data/中华一万年1.txt");
	        //初始化美食译苑分析工具
			Msyy t = new Msyy(null,dao);
			//////////指定待分析的文本路径
			//t.readFile("/Users/chen4w/rm/st2/json/node.txt");
			//指定中餐馆名称,中餐馆名称译名,用户id,将分析结果写入数据库,如果已经存在同名的餐馆,将删除该餐馆所有相关数据,并重新写入
			//t.outputToDB("美食译苑之中餐","Chinese Cuisine",1);
			
			t.readFile("/Users/chen4w/rm/st2/json/node_uk.txt");
			//指定中餐馆名称,中餐馆名称译名,用户id,将分析结果写入数据库,如果已经存在同名的餐馆,将删除该餐馆所有相关数据,并重新写入
			t.outputToDB("美食译苑之西餐","Western cuisine",1);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
